# BSD 3-Clause 2023 by Kevin Bloom.

BEGIN {
  i = 0
}
/aledger error/ {
  print $0
  exit 1
}
$1 ~ ":" {
  chh = ""
  sub("\\$", "", $2)
  split($1, accs, ":")
  for(k = 1; k <= length(accs); k++) {
    if(chh != "")
      chh = chh ":" accs[k]
    else
      chh = accs[k]
    if(test[chh] == "")
      test[chh] = $2
    else
      test[chh] += $2
  }
}
END {
  for(k in test) {
    print k "  " test[k]
  }
}
